package org.kabeja.parser.entities;

import org.kabeja.dxf.entity.DXFDimension;
import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/28 17:14
 */
public class DXFDimensionHandler extends AbstractEntityHandler {
    protected static final int GROUPCODE_REFERENCE_POINT_X = 10;
    protected static final int GROUPCODE_REFERENCE_POINT_Y = 20;
    protected static final int GROUPCODE_REFERENCE_POINT_Z = 30;
    protected static final int GROUPCODE_TEXT_POINT_X = 11;
    protected static final int GROUPCODE_TEXT_POINT_Y = 21;
    protected static final int GROUPCODE_TEXT_POINT_Z = 31;
    protected static final int GROUPCODE_INSERT_POINT_X = 12;
    protected static final int GROUPCODE_INSERT_POINT_Y = 22;
    protected static final int GROUPCODE_INSERT_POINT_Z = 32;
    protected static final int GROUPCODE_REFERENCE_POINT3_X = 13;
    protected static final int GROUPCODE_REFERENCE_POINT3_Y = 23;
    protected static final int GROUPCODE_REFERENCE_POINT3_Z = 33;
    protected static final int GROUPCODE_REFERENCE_POINT4_X = 14;
    protected static final int GROUPCODE_REFERENCE_POINT4_Y = 24;
    protected static final int GROUPCODE_REFERENCE_POINT4_Z = 34;
    protected static final int GROUPCODE_REFERENCE_POINT5_X = 15;
    protected static final int GROUPCODE_REFERENCE_POINT5_Y = 25;
    protected static final int GROUPCODE_REFERENCE_POINT5_Z = 35;
    protected static final int GROUPCODE_REFERENCE_POINT6_X = 16;
    protected static final int GROUPCODE_REFERENCE_POINT6_Y = 26;
    protected static final int GROUPCODE_REFERENCE_POINT6_Z = 36;
    protected static final int GROUPCODE_DIMENSION_STYLE = 3;
    protected static final int GROUPCODE_DIMENSION_BLOCK = 2;
    protected static final int GROUPCODE_DIMENSION_AREA = 67;
    protected static final int GROUPCODE_DIMENSION_TEXT = 1;
    protected static final int GROUPCODE_LEADINGLINE_LENGTH = 40;
    protected static final int GROUPCODE_DIMENSION_ROTATE = 50;
    protected static final int GROUPCODE_HORIZONTAL_ALIGNMENT = 51;
    protected static final int GROUPCODE_INCLINATION_HELPLINE = 52;
    protected static final int GROUPCODE_TEXT_ROTATION = 53;
    protected static final int GROUPCODE_DIMENSION_TYPE = 70;
    protected String ENTITY_NAME = "DIMENSION";
    protected DXFDimension dimension;

    public DXFDimensionHandler() {
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.dimension;
    }

    @Override
    public String getDXFEntityName() {
        return this.ENTITY_NAME;
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 1:
                this.dimension.setDimensionText(var2.getValue());
                break;
            case 2:
                this.dimension.setDimensionBlock(var2.getValue());
                break;
            case 3:
                this.dimension.setDimensionStyleID(var2.getValue());
                break;
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 17:
            case 18:
            case 19:
            case 27:
            case 28:
            case 29:
            case 37:
            case 38:
            case 39:
            case 41:
            case 42:
            case 43:
            case 44:
            case 45:
            case 46:
            case 47:
            case 48:
            case 49:
            case 54:
            case 55:
            case 56:
            case 57:
            case 58:
            case 59:
            case 60:
            case 61:
            case 62:
            case 63:
            case 64:
            case 65:
            case 66:
            case 68:
            case 69:
            default:
                super.parseCommonProperty(var1, var2, this.dimension);
                break;
            case 10:
                this.dimension.getReferencePoint().setX(var2.getDoubleValue());
                break;
            case 11:
                this.dimension.getTextPoint().setX(var2.getDoubleValue());
                break;
            case 12:
                this.dimension.getInsertPoint().setX(var2.getDoubleValue());
                break;
            case 13:
                this.dimension.getReferencePoint3().setX(var2.getDoubleValue());
                break;
            case 14:
                this.dimension.getReferencePoint4().setX(var2.getDoubleValue());
                break;
            case 15:
                this.dimension.getReferencePoint5().setX(var2.getDoubleValue());
                break;
            case 16:
                this.dimension.getReferencePoint6().setX(var2.getDoubleValue());
                break;
            case 20:
                this.dimension.getReferencePoint().setY(var2.getDoubleValue());
                break;
            case 21:
                this.dimension.getTextPoint().setY(var2.getDoubleValue());
                break;
            case 22:
                this.dimension.getInsertPoint().setY(var2.getDoubleValue());
                break;
            case 23:
                this.dimension.getReferencePoint3().setY(var2.getDoubleValue());
                break;
            case 24:
                this.dimension.getReferencePoint4().setY(var2.getDoubleValue());
                break;
            case 25:
                this.dimension.getReferencePoint5().setY(var2.getDoubleValue());
                break;
            case 26:
                this.dimension.getReferencePoint6().setY(var2.getDoubleValue());
                break;
            case 30:
                this.dimension.getReferencePoint().setZ(var2.getDoubleValue());
                break;
            case 31:
                this.dimension.getTextPoint().setZ(var2.getDoubleValue());
                break;
            case 32:
                this.dimension.getInsertPoint().setZ(var2.getDoubleValue());
                break;
            case 33:
                this.dimension.getReferencePoint3().setZ(var2.getDoubleValue());
                break;
            case 34:
                this.dimension.getReferencePoint4().setZ(var2.getDoubleValue());
                break;
            case 35:
                this.dimension.getReferencePoint5().setZ(var2.getDoubleValue());
                break;
            case 36:
                this.dimension.getReferencePoint6().setZ(var2.getDoubleValue());
                break;
            case 40:
                this.dimension.setLeadingLineLength(var2.getDoubleValue());
                break;
            case 50:
                this.dimension.setDimensionRotation(var2.getDoubleValue());
                break;
            case 51:
                this.dimension.setHorizontalAlign(var2.getDoubleValue());
                break;
            case 52:
                this.dimension.setInclinationHelpLine(var2.getDoubleValue());
                break;
            case 53:
                this.dimension.setTextRotation(var2.getDoubleValue());
                break;
            case 67:
                this.dimension.setDimensionArea(var2.getIntegerValue());
                break;
            case 70:
                this.dimension.setDimensionType(var2.getIntegerValue());
        }

    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.dimension);
    }

    @Override
    public void startDXFEntity() {
        this.dimension = new DXFDimension();
    }
}
